<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<script LANGUAGE="javascript">
function redirectPageComplete(id)
{	
	alert("ลบสินค้าย่อยสำเร็จ");
	location = "../../subCategories.php?main_id="+id;
}

function redirectPageIncomplete(id)
{
	alert("เกิดข้อผิดพลาดในการลบข้อมูล");
	location = "../../subCategories.php?main_id="+id;
}

function redirectPageIsnull(id)
{
	alert("ข้อมูลบางส่วนยังเป็นค่าว่าง กรุณาลงใหม่อีกครั้ง");
	location = "../../subCategories.php?main_id="+id;	
}

<?php
include '../../../inc/reuse/dbconfig.php';
$subCategory_id = addslashes($_GET['subCategory_id']);
$mainCategory_id = addslashes($_GET['mainCategory_id']);
if(isset($subCategory_id)){
	$sql = "DELETE FROM fix_sub_products_type
			WHERE fix_sub_products_type_id=$subCategory_id";
	if(mysql_query($sql)){
	 	echo "redirectPageComplete($mainCategory_id);";
	}else{	
		echo "redirectPageIncomplete($mainCategory_id);";
	}	
	mysql_close();	
}
else
{
	echo "redirectPageIsnull();";
}
?>
</script>
</body>
</html>
